package com.bt.controller.admin;
import com.bt.dto.YddAdvimgDTO;
import com.bt.dto.YddAdvimgPageQueryDTO;
import com.bt.result.PageResult;
import com.bt.result.Result;
import com.bt.service.YddAdvimgService;
import com.bt.vo.YddAdvimgVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description TODO
 * @Author itheima
 * @Date 2023-05-02 17:20
 */
@Slf4j
@Api(tags = "广告管理接口")
@RestController
@RequestMapping("/ydd_advimg")
public class YddAdvimgController {

    @Autowired
    private YddAdvimgService yddAdvimgService;

    /**
     * 广告图详情
     *
     * @return
     */
    @GetMapping("/rowInfo")
    @ApiOperation("广告图详情接口")
    public Result rowInfo(Integer id) {
        log.info("广告图详情{}", id);
        YddAdvimgVO yddAdvimgVO = yddAdvimgService.rowInfo(id);
        return Result.success(yddAdvimgVO);
    }

    /**
     * 广告图列表-分页
     *
     * @return
     */
    @ApiOperation("广告图列表-分页接口")
    @GetMapping("/list")
    public Result list(YddAdvimgPageQueryDTO yddAdvimgPageQueryDTO) {
        log.info("广告图列表-分页{}", yddAdvimgPageQueryDTO);
        PageResult pageResult =yddAdvimgService.list(yddAdvimgPageQueryDTO);
        return Result.success(pageResult);
    }


    /**
     * 广告图修改
     *
     * @param yddAdvimgDTO
     * @return
     */
    @ApiOperation("广告图修改接口")
    @PostMapping("/update")
    public Result update(@RequestBody YddAdvimgDTO yddAdvimgDTO) {
        log.info("广告图修改{}", yddAdvimgDTO);
        yddAdvimgService.update(yddAdvimgDTO);
        return Result.success();
    }

    /**
     * 广告图删除
     *
     * @param id
     * @return
     */
    @ApiOperation("广告图删除接口")
    @GetMapping("/del")
    public Result del(Integer id) {
        log.info("广告图删除{}", id);
        yddAdvimgService.del(id);
        return Result.success();
    }

    /**
     * 广告图添加
     *
     * @return
     */
    @ApiOperation("广告图添加接口")
    @PostMapping("/add")
    public Result add(@RequestBody YddAdvimgDTO yddAdvimgDTO) {
        log.info("链接添加{}", yddAdvimgDTO);
        yddAdvimgService.add(yddAdvimgDTO);
        return Result.success();
    }
}
